import config from "@/config"
import http from "@/utils/request"

export default {
    dict: {
        url: `${config.API_URL}/sys/dict`,
        name: "字典管理",
        get: async function (data) {
            return await http.get(this.url, data);
        },
        post: async function (data) {
            return await http.post(this.url, data);
        },
        put: async function (data) {
            return await http.put(this.url + `/${data.id}`, data);
        },
        switch: async function (data) {
            return await http.put(this.url + `/${data.id}/status/${data.status}`);
        },
        tree: async function () {
            return await http.get(this.url + `/options`);
        },
        exists: async function (fieldName, fieldValue, id) {
            return await http.get(this.url + `/exists/${fieldName}/${fieldValue}/${id}`);
        },
        delete: async function (id) {
            return await http.delete(this.url + `/${id}`);
        },
        detail: {
            url: `${config.API_URL}/sys/dict/options/`,
            name: "字典项列表",
            get: async function (data) {
                return await http.get(this.url + data.name);
            },
            map: async function (ids) {
                return await http.get(this.url + ids.join());
            },
        }
    },
    dictDetail: {
        url: `${config.API_URL}/sys/dict-detail`,
        name: "字典项管理",
        post: async function (data) {
            return await http.post(this.url, data);
        },
        put: async function (data) {
            return await http.put(this.url + `/${data.id}`, data);
        },
        switch: async function (data) {
            return await http.put(this.url + `/${data.id}/status/${data.status}`);
        },
        get: async function (params) {
            return await http.get(this.url, params);
        },
        exists: async function (fieldName, fieldValue, id) {
            return await http.get(this.url + `/exists/${fieldName}/${fieldValue}/${id}`);
        }
    },
    menu: {
        myMenus: {
            url: `${config.API_URL}/sys/menu/my/1.6.1`,
            name: "获取我的菜单",
            get: async function () {
                return await http.get(this.url);
            }
        },
        url: `${config.API_URL}/sys/menu`,
        name: "获取菜单",
        post: async function (data) {
            return await http.post(this.url, data);
        },
        put: async function (data) {
            return await http.put(this.url + `/${data.id}`, data);
        },
        get: async function (params) {
            return await http.get(this.url, params);
        },
        delete: async function (id) {
            return await http.delete(this.url + `/${id}`);
        },
        routes: async function (data) {
            return await http.get(this.url + '/routes', data);
        },
        tree: async function () {
            return await http.get(this.url + `/options`);
        }
    },
    role: {
        url: `${config.API_URL}/sys/role`,
        name: "获取角色列表",
        get: async function (params) {
            return await http.get(this.url, params);
        },
        post: async function (data) {
            return await http.post(this.url, data);
        },
        put: async function (data) {
            return await http.put(this.url + `/${data.id}`, data);
        },
        delete: async function (id) {
            return await http.delete(this.url + `/${id}`);
        },
        switch: async function (data) {
            return await http.put(this.url + `/${data.id}/status/${data.status}`);
        },
        exists: async function (fieldName, fieldValue, id) {
            return await http.get(this.url + `/exists/${fieldName}/${fieldValue}/${id}`);
        },
        options: async function () {
            return await http.get(this.url + `/options`);
        }
    },
    dept: {
        url: `${config.API_URL}/sys/dept`,
        name: "获取部门列表",
        get: async function (params) {
            return await http.get(this.url, params);
        },
        post: async function (data) {
            return await http.post(this.url, data);
        },
        put: async function (data) {
            return await http.put(this.url + `/${data.id}`, data);
        },
        delete: async function (id) {
            return await http.delete(this.url + `/${id}`);
        },
        tree: async function () {
            return await http.get(this.url + `/options`);
        }
    },
    config: {
        url: `${config.API_URL}/sys/config`,
        name: "获取运营参数列表",
        get: async function (params) {
            return await http.get(this.url, params);
        },
        post: async function (data) {
            return await http.post(this.url, data);
        },
        put: async function (data) {
            return await http.put(this.url + `/${data.id}`, data);
        },
        delete: async function (id) {
            return await http.delete(this.url + `/${id}`);
        },
        switch: async function (data) {
            return await http.put(this.url + `/${data.id}/status/${data.status}`);
        },
        exists: async function (fieldName, fieldValue, id) {
            return await http.get(this.url + `/exists/${fieldName}/${fieldValue}/${id}`);
        }
    },
    user: {
        url: `${config.API_URL}/sys/user`,
        name: "获取用户列表",
        get: async function (params) {
            return await http.get(this.url, params);
        }
    },
    app: {
        list: {
            url: `${config.API_URL}/system/app/list`,
            name: "应用列表",
            get: async function () {
                return await http.get(this.url);
            }
        }
    },
    log: {
        list: {
            url: `${config.API_URL}/system/log/list`,
            name: "日志列表",
            get: async function (params) {
                return await http.get(this.url, params);
            }
        }
    },
    table: {
        list: {
            url: `${config.API_URL}/system/table/list`,
            name: "表格列管理列表",
            get: async function (params) {
                return await http.get(this.url, params);
            }
        },
        info: {
            url: `${config.API_URL}/system/table/info`,
            name: "表格列管理详情",
            get: async function (params) {
                return await http.get(this.url, params);
            }
        }
    },
    tasks: {
        list: {
            url: `${config.API_URL}/system/tasks/list`,
            name: "系统任务管理",
            get: async function (params) {
                return await http.get(this.url, params);
            }
        }
    }
}
